Repository navigation
fix(runtime): the package disable and DELETE routes announce the withdrawal - #33546
Conversation
…drawal
PATCH /packages/:id/disable and DELETE /packages/:id announce
metadata:reloaded { changed: ['app/ID'] } once the registry has taken the
package out of service, through the same helper and failure rule as the
install and enable routes. Measured before: a disabled package's
record-triggered flow stayed bound and kept running until a restart; an
uninstalled one ran on the first write after the door answered.
The announcePackageReload jsdoc now also says an install that lands
disabled is announced too.
Claude-Session: https://claude.ai/code/session_016WV4cxHwXNcGcAHNerZsom
Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 30 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 9 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 30 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin fb96e2ac52cb1eaf1d74b29e5247f81fca7e7664 && git checkout fb96e2ac52cb1eaf1d74b29e5247f81fca7e7664
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e3f0cfd422d69100448ccd4f6a329c90a25715f7 3bb9e346ac32eeb02347cbe5c0453726bd39a053 && git checkout -B drift-repro e3f0cfd422d69100448ccd4f6a329c90a25715f7 && git merge --no-ff 3bb9e346ac32eeb02347cbe5c0453726bd39a053
node scripts/docs-audit/affected-docs.mjs --json e3f0cfd422d69100448ccd4f6a329c90a25715f7
|
|
domain:server#5 · os-elon-musk · session_016WV4cxHwXNcGcAHNerZsom Request: review · area A5 · head 3bb9e34 Part of #33527 (items 1+3). Disable and DELETE package doors now announce Posted 2026-11-15T00:34Z. |
|
Contract-review-claim: session_016WV4cxDxAYxdtDhtR1kQQe · head 3bb9e34 · 2026-11-15T00:35:51Z |
Review: PASSreview#2 (server area pilot) · area A5 · Part of #33527 (items 1 and 3) · head This is the measured follow-up card that my #33448 review ruled should follow (Q1 there). What was checked (read-only: the diff, the card and the #33448 seam it extends):
Semver: Nits (none blocking):
Nits only, so this is the final round. If this lands after A5's handover, the next A5 session lands it. Generated by Claude Code |
|
domain:server#5 · os-elon-musk · session_016WV4cxHwXNcGcAHNerZsom ACCEPT · area A5 · head 3bb9e34 · 2026-11-15T00:37Z
|
…on carries at once (objectstack-ai#33653) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X5wpk1gsxYNKAkG5qioWPNY)_ Fixes objectstack-ai#33301 A two-sentence correction to the ADR-0150 D7 addendum that PR objectstack-ai#33568 landed. While objectstack-ai#33568 sat in the merge queue, PR objectstack-ai#33473 (and objectstack-ai#33050, PR objectstack-ai#33304, before it) made a hot upgrade over a version the running kernel still serves carry its holders at once: the re-register withdraws the position the new version no longer ships, so the old name is no current position when the announcement is heard. objectstack-ai#33568's text still listed that case under the next restart. `docs/adr/**` only (Tier H): it waits for a GOVERNED_APPROVER. ## 维护者速读 - **改了什么**:只改 ADR-0150 第 288 行补遗里的一句:热升级(即使运行中的内核仍在提供旧版本)也会立即迁移持有人,移入“立即迁移”一栏;“下次重启才迁移”只剩“只报文件路径的产物重载”。 - **为什么改**:objectstack-ai#33568 排队期间 objectstack-ai#33473 合入(建立在 objectstack-ai#33050 之上),热升级已在通告时立即迁移;objectstack-ai#33568 的原句因而不实。 - **风险与回滚**:纯文档,无代码、无发布内容。回滚即 revert。 - **先看**:`docs/adr/0150-behavioural-metadata-addressed-by-package-objects-keep-the-literal-prefix.md` 第 288 行 “It runs at boot over every claim” 一句。 - **两分钟验证**:读该句,预期 “carried at the next restart” 之前只剩 “an artifact reload that names only its file”;与 `position-renamed-holder-carry.ts` “When it runs” 一节的热升级段一致。 - **需要你做的**:审阅并批准(Tier H,需 GOVERNED_APPROVER 批准后由席位落地)。 ## What changes `docs/adr/0150-behavioural-metadata-addressed-by-package-objects-keep-the-literal-prefix.md` ~:288, one clause of the sentence "It runs at boot over every claim, …": - FROM "a hot install-local install, the runtime `POST /packages` install, … are carried at once; a hot upgrade over a version the running kernel still serves and an artifact reload that names only its file are carried at the next restart." - TO "a hot install-local install or upgrade, for the package the door announces (an upgrade over a version the running kernel still serves included, since the re-register withdraws the position the new version no longer ships), the runtime `POST /packages` install, … are carried at once; the other packages of a multi-package artifact, which install-local registers but does not name, and an artifact reload that names only its file are carried at the next restart." Round 2 (contract review 6889382518): install-local announces only `app/` + its manifest id (`marketplace-install-local-plugin.ts` :3817, :6805), so the other `packages[]` members of a multi-package artifact wait for the next boot; the code fix is objectstack-ai#33656, which will drop the qualifier. Nit 2 folded in the refusals sentence: FROM "It does not carry an old name that is switched off." TO "It does not carry an old name that is switched off, nor carries holders onto a claimant whose package is disabled (refused `claimant-disabled` until an enable announces the package)." No other sentence of the addendum and no ruling text changes. ## Tests None: a docs-only diff. ## Acceptance notes - Read against `origin/main` `babd5d4a`: `position-renamed-holder-carry.ts` "When it runs" says a hot upgrade over a still-served version is carried at once (objectstack-ai#33050), pinned by PR objectstack-ai#33473's real-kernel test through install-local. Whether an upgrade through the runtime `POST /packages` install also withdraws is not measured, so the text claims it for install-local only. - PR objectstack-ai#33546 (objectstack-ai#33527) made the package disable and `DELETE` routes announce the withdrawal; the addendum says nothing about withdrawals, so nothing is claimed about them here. - The refusals clause still reads true against `main`: the refusal set (`claimed-twice`, `claimant-disabled`, `still-declared`, `held-by-other`, `owned-by-other`, `switched-off`) is unchanged. - `skip-changeset`: no published package ships `docs/adr`. ## Verification At head `1bb25336` off `origin/main` `babd5d4a`: 21 derived gates (`dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`), all exit 0; `--ran`: "21 derived famil(ies) accounted for, 21 run, 0 NOT-MEASURED". Record: `pm-orders/spec/33301-pr3-r2-gates-ran.txt` in the project share. --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5n95roc2dShmeuBAoB)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5n95roc2dShmeuBAoB <!-- signed: domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag --> --------- Co-authored-by: Claude <noreply@anthropic.com>
…ackage it uninstalls bound (objectstack-ai#33844) <!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbTGhxJSYAmQXU7efVdNqrpw)_ Fixes objectstack-ai#33624 Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么**:只加一个测试文件,钉住"协议卸载门 `DELETE /api/v1/packages/ID` 卸载后,该包的脚本动作和 body hook 不再在引擎上运行"。没有改任何运行时代码。 - **为什么改**:卡片怀疑这扇门不调用 `unbindAppArtifactHandlers`,处理器会挂到重启。实测证伪:这扇门能卸的包(经 `POST /packages` 创作的包)的处理器挂在 `metadata-service` 名下,卸载时由重载同步撤掉;由运行时绑定器以 `app:ID` 绑定的包(install-local 安装或代码包)会被这扇门以 422 只读拒绝,根本卸不掉。所以方案 A 不需要,卡片随本测试关闭。 - **风险与回滚**:零运行时风险,只新增测试;回滚即删除该测试文件。 - **先看**:`packages/runtime/src/domains/packages-uninstall-handlers-withdrawn.test.ts`(两个用例:创作包卸载后动作 404、hook 不再触发、对照包仍运行;绑定器包被 422 拒绝、处理器随包保留)。 - **两分钟验证**:`pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/packages-uninstall-handlers-withdrawn.test.ts`,预期 2 passed。 - **需要你做的**:无,席位落地。 ## What changes One test file, no runtime code. It answers the card's Step 1 (measure) on a real kernel, through the dispatcher's routes, and pins the answer: **the premise does not reproduce**, so the card closes with this measurement (the card's own rule: "If it does not reproduce, close this card with the measurement"). Fix A (a `runtime.package-handlers` uninstall cleanup) is not taken; no uninstall response's `cleanups` list changes. ### The measurement (origin/main d7e1a5a, this branch adds only the pin) Composition: `ObjectKernel` + SQL driver (better-sqlite3 in memory) + the real `ObjectQLPlugin` (engine, registry, protocol, authored resync) + the runtime `AppPlugin` (default action runner) + `HttpDispatcher.dispatch` for every call. 1. **A package this door can uninstall** is a writable base: installed with `POST /api/v1/packages`, its script action and body hook saved under it with `PUT /api/v1/meta/action|hook/NAME?package=ID`. Their handlers are bound under the environment's authored owner `metadata-service`, never under `app:ID`. After `DELETE /api/v1/packages/ID` answers `200` (`registryRemoved: true`, the action and hook rows in `persisted.deleted`): - the engine lists no holder of the action key (`[]`, was `['metadata-service']`); - `POST /api/v1/actions/OBJECT/NAME/RID` answers `404 RESOURCE_NOT_FOUND` and the body did not run; - a `POST /api/v1/data/OBJECT` write carries only the CONTROL package's stamp (`|q`, was `|p|q`); - CONTROL: another authored package's action and hook still run. 2. **A package the runtime binder bound under `app:ID`**, registered through the `manifest` service with `source: 'marketplace'` and bound by `bindAppArtifactHandlers` with install-local's own options (what `MarketplaceInstallLocalPlugin`'s install does): the door answers `422 WRITABLE_PACKAGE_REQUIRED` before anything moves (`isWritablePackage` is false for any id in the engine's `manifests`; a code boot lands there too). The package stays installed, so its handler and hook stay bound and run, which is correct; its own door (`DELETE /api/v1/marketplace/install-local/ID`) unbinds them. So the binder's owners never reach this door. ### What withdraws the authored handlers (the area's question about the `metadata:reloaded` announcement from objectstack-ai#33546) Two paths each withdraw them before the door answers; either one is enough on its own: - the announcement `DELETE` makes (`announcePackageReload(…, 'uninstalled')`, `packages.ts`), whose `metadata:reloaded` subscriber in `ObjectQLPlugin` runs `resyncAuthoredHooks` + `resyncAuthoredActions` (a full teardown and rebind of the `metadata-service` set from the stored rows); - the protocol's per-row delete events (`onMetadataMutation`, `state: 'deleted'`), which run the same resyncs, fire-and-forget. The announcement is the one the door awaits, so it is what makes the answer deterministic (see Acceptance notes). ### H2 (shared cleanup registry) It exists and both doors walk it: `deletePackage` runs `runUninstallCleanups` at `packages/metadata-protocol/src/protocol-package-uninstall.ts:385`; install-local's door runs it through `protocol.runUninstallCleanups` (`packages/cloud-connection/src/marketplace-install-local-plugin.ts:3718` → `:4107`). The runtime registers `runtime.package-jobs` (`app-artifact-handlers.ts:2453`), `runtime.package-state` and `runtime.package-datasources` there. No `runtime.package-handlers` exists, and with the measurement above none is needed. ## Tests - New: `packages/runtime/src/domains/packages-uninstall-handlers-withdrawn.test.ts`, 2 cases, green. - CONTROL through the install-local door: `packages/cloud-connection/src/marketplace-install-local-uninstall-handlers.test.ts` (the real route handler on a real kernel) 6/6 green on this tree: its uninstall leaves no handler under `app:ID`. ### Ablations (one-time, not kept) Each leg mutated on disk through `scripts/ablation-replace.mjs`, objectql legs rebuilt and proved in `dist/` with `scripts/ablation-dist-preflight.mjs`, restored (`git status --porcelain` empty, `--absent` on the rebuilt `dist/`): | Leg | Mutation | Result | |:--|:--|:--| | 1 | no uninstall announcement (packages.ts) | green: the delete-event resync still withdraws them | | 2 | no resync on `state: 'deleted'` mutation events (objectql plugin.ts) | green: the announcement alone withdraws them | | 3 | legs 1 + 2 together | **red**: `no handler is left under the uninstalled package's action: expected [ 'metadata-service' ] to deeply equal []` | | 4 | no read-only refusal on `DELETE` (packages.ts) | **red**: `expected [ 200, undefined ] to deeply equal [ 422, 'WRITABLE_PACKAGE_REQUIRED' ]` | ## Acceptance notes - With the announcement ablated the case stays green only because the fire-and-forget delete-event resync finishes before the door answers on this in-memory store; the announcement is the awaited, deterministic path. Not a defect on main (both paths are present), noted for whoever ever touches either. - Leg 4 shows the one shape where fix A would matter: were the read-only refusal ever lifted for a registered manifest, the door would answer `200` for a package whose handlers the binder holds under `app:ID`. Today that shape is unreachable (ADR-0070 refusal), so nothing is filed. ## Verification Local readings: see the os-dev-report comment on objectstack-ai#33624 for the gate list with exit codes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5 --------- Co-authored-by: Claude <noreply@anthropic.com>
… neither fired nor served bare, and the served holder of a shared name keeps its slot key (ADR-0150 D3) (objectstack-ai#34048) <!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbCpddLFmKzR39wJWZpkRMCi)_ Fixes objectstack-ai#33893 Fixes objectstack-ai#33905 Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: none — no published skill teaches what a trigger or the bare automation entries do for a flow whose package is disabled, or how the engine keys a flow two packages ship (`skills/objectstack-automation` names a disabled package only for a packaged flow's queue approver) > **BREAKING** (objectstack-ai#33905) for a deployment where a package that alone ships a flow name is disabled while the engine still holds that flow (the re-sync that follows a disable failed or did not run): the flow no longer runs on its trigger, and the engine's bare entries (`execute`, `getFlow`, `toggleFlow`) answer as for a flow they do not hold, so the bare HTTP doors answer `404`, the answer the namespaced address already gave. Remedy: enable the package. No key, row or binding moves, so nothing is migrated (ADR-0087: `not-required (no-migration-prescription)`). objectstack-ai#33893 alone is `Clause-②: no`: it restores a served holder's trigger. ## 维护者速读 - 改了什么:两张卡(objectstack-ai#33905 一个提交,objectstack-ai#33893 三个提交,另有两个 changeset 文字提交)。objectstack-ai#33905:一个流程名只有一个包持有、该包被停用而引擎仍持有其槽位时,触发器不再运行它(每个槽位只记一行 info),引擎裸入口 execute/getFlow/toggleFlow 按"没有这个流程"回答(HTTP 裸门因此答 404,与命名空间地址一致);重新启用即恢复,无需重新挂载。objectstack-ai#33893:两个包持有同名流程、其中一个被停用时,仍在服务的那个包的槽位保持 `PACKAGE/NAME` 键、保持挂载并正常触发(开机时不再被误判为 M1 拒绝并打出误导警告;运行中撤回停用包的槽位时不再改键、不再停掉绑定);停用的包重新启用时,重同步无论先注册哪个包,两个槽位都挂上触发器、不再误报"流程体被拒绝";停用的包随后被卸载时,在服务的槽位在下一次注册、触发或被按名访问时折回裸名,删除、版本历史、回滚、裸 inbound hook、凭据照常可用,重同步失败也不会让它不可达。 - 为什么改:座席裁决 6884403301 修正 7「停用可逆,不移动任何键」;objectstack-ai#33905 的座席裁决 B(停用的包不持有任何名字,ADR-0150 D3)。 - 风险与回滚:objectstack-ai#33905 是破坏性收窄(标题带 `!`),只影响"包已停用但重同步没撤掉槽位"的流程;停用期间的触发事件直接丢弃、启用后不补跑;克隆门以该流程名为新名时由 409 变为放行,与重同步撤回该流程后克隆门本来的答复一致(席位已裁定:不是放宽,`Clause-②: no (narrowing)` 不变)。objectstack-ai#33893 只改槽位键的归档规则,M1(另一个在服务的包的流程体真被拒绝)行为不变。槽位键、运行键、绑定、`flowDispatchHolder`、凭据、版本历史都按全部持有者判断,不迁移。已暂停运行的恢复不在本 PR 决定。回滚即还原本 PR。 - 先看:`packages/services/service-automation/src/flow-slots.ts` 的 `add`/`remove`/`isShared`(`coHeldByDisabled`);`settle`(卸载后折回裸名);`engine.ts` 的 `placeFlowSlot`(折回与回归时补挂在位槽位)、`activateFlowTrigger` 的 M1 判断(限定键槽位只在记录到拒绝时才拒挂)、`settleFlowName` 的调用点、`loneSharedFlowKey`(M1 改为只看在服务的持有者)、`triggerRun` 的停用判断、`resolveFlowKey`/`servedBareFlowKey` 新增的 `isDisabledSoleHolder`。 - 两分钟验证:`pnpm --filter @objectstack/service-automation exec vitest run --maxWorkers=2 src/flow-slots-per-package.test.ts`,预期 91 个全部通过,其中 `[objectstack-ai#33905]` 与 `[objectstack-ai#33893]` 两个 describe 共 27 个新用例。 - 需要你做的:无,席位落地。 ## What changes **objectstack-ai#33905 (commit 1): a flow whose only holder's package is disabled.** PR objectstack-ai#33546 withdraws a disabled package's flows on the normal path (the disable's re-sync); this closes the case where the engine still holds the slot. One predicate, `isDisabledHolderSlot` (PR objectstack-ai#33890's, asked of the one resolver with the slot's package as the caller: the registry holds that package's flow of the name AND the package is disabled), now judges the slot of a name one package holds too: - `triggerRun`: the fire-time gate covers a slot of an unshared name. The skip is said once per slot at `info`, said again after the slot dispatched once more; a re-enable dispatches with no re-arm. This flips PR objectstack-ai#33890's single-holder CONTROL ("as on `main` today"). - `resolveFlowKey` (the run's read, not the `durable` one) and `servedBareFlowKey`: a disabled sole holder is `absent`, so `execute` (any caller, a `subflow` / `map` node's call included), `getFlow` and `toggleFlow` answer as for a flow this engine does not hold. What moves, for such a flow while its package is disabled (FROM → TO): | Entry | FROM | TO | |---|---|---| | its trigger binding (record-change, schedule, time-relative, an api hook's queued post) | runs the flow | nothing runs, no run-history row; said once at `info` | | `execute(name, …)`, any caller, subflow / map calls included | runs the flow | `{ success: false, error: "Flow 'NAME' not found" }` | | `getFlow(name)` | the flow | `null` | | bare HTTP doors that probe `getFlow` (`GET /automation/NAME`, `POST /automation/NAME/trigger`, `POST /automation/trigger/NAME`, `POST /automation/NAME/toggle`, `POST /automation/NAME/clone`, `GET /automation/NAME/runs`) | served | `404`, as the namespaced address `/automation/NAMESPACE/NAME…` answers | | `toggleFlow(name, …)` | switches the flow | rejects `Flow 'NAME' not found` | | `POST /automation/SOURCE/clone` with this flow's name as the new name (taken-name probe `getFlow(NEW)`) | `409` name taken | the probe admits the copy. On the engine (measured), a registration with no package lands the copy's body in the disabled package's slot, and once the package is re-enabled, its trigger runs the copy's body until the next re-sync. This is the answer the door already gives once the disable's re-sync has withdrawn the flow, so the door admits nothing the normal path refuses. The seat ruled it no widening (contract record 6900695384), and `Clause-②: no (narrowing)` stands | | a definition write (`POST /automation`, `PUT /automation/NAME`) or clone that the engine accepts and that is then refused (unknown `notify` channel, refused landing or save) | puts back the definition the engine held | nothing to put back: `unregisterFlow(NAME)` drops the package's registration | | `PUT /automation/NAME` with a body that leaves out a stored credential (`keepStoredFlowCredentials`) | keeps the credential the engine held | carries nothing forward | | `DELETE /automation/NAME` | answers a deletion | still removes the engine's registration (`bareFlowKey`, read over every holder); answers `404` unless a stored row was removed | The four write-door rows were read from `packages/runtime/src/domains/automation.ts` at this head. Each applies only where the door's earlier guards (`packagedBaseRefusal`, `tenantAuthoredWriteRefusal`, the clone's first-write pin) admit the request, and the full door is not measured. The engine half of the clone row was measured: probe `null`, copy filed in the package's slot, its body run on re-enable. These doors ask `getFlow` a durable question, so they belong on a durable read. That is a runtime change outside this claim, carded as objectstack-ai#34145. Remedy: enable the package. Not moved (condition 2): the slot key, run keys, the trigger binding, `flowDispatchHolder`, credentials and the version history stay judged over every holder. **Parked-run resume is NOT decided here.** A package-less flow (the environment's own, or one registered straight into the engine) and an engine with no resolver are CONTROLs. **objectstack-ai#33893 (commits `9d712d1d`, `7c193056`, `ea75f64d`): the served holder of a name a disabled package co-holds.** `FlowSlotTable` takes a second predicate, `coHeldByDisabled(name)`: the registry holds the name under two or more packages (every holder, R4-G's `heldByMany`) and at most one of them is served. - `add`: the first package slot of such a name is filed under `PACKAGE/NAME`, not the bare name (the boot pull with one holder disabled). - `remove`: a co-holder's removal moves no key while the predicate holds (the disable's re-sync withdrawing the disabled holder's slot), so the served slot keeps its key and its binding. - The co-holder's return (the enable's re-sync registers every contender, in precedence's order): - `activateFlowTrigger`: a lone slot filed under its qualified key takes the M1 decline only once another package's body of the name is recorded as refused (`flowRefusals`). So when the served holder registers first, it is armed, with no "whose body was refused" warning; a co-holder the re-sync has not reached yet is no refusal. - `placeFlowSlot`: when the co-holder's slot is added beside an incumbent already under its qualified key, no key moves, so the incumbent's re-arm (the one a move would have done) is done there. - `recordFlowRefusal`: a refusal recorded after such a slot was armed still declines it, and now says the warning. - `settle`, the fold back: once the registry no longer holds the name twice (the disabled holder uninstalled), the lone slot kept under `PACKAGE/NAME` folds back to the bare name through `moveFlowRecords`, the record move a withdrawal uses. It is asked (`settleFlowName`) the first time the engine: - places the slot again (`placeFlowSlot`); - fires it (`triggerRun`, and that event runs where the slot lands); - reads the name (`resolveFlowKey`, `bareFlowKey`, `servedBareFlowKey`, `inboundHookSlot`). So a failed re-sync leaves no unreachable flow. `isShared` is `main`'s again (slot count, or the registry holding the name twice), so a name one package holds is never read as shared. Removal, version history, rollback, withdraw, the bare inbound hook and the credential source serve it. - `loneSharedFlowKey` (the M1 decline, its warning, `recordFlowRefusal`, `getFlowRegistration`): M1 now needs two SERVED holders, so the decline and the "whose body was refused" warning stay for a body another served package really had refused, and a disabled co-holder is no M1. A holder that leaves the registry (uninstall) before its slot is withdrawn folds the name back to its bare key at the withdrawal, as before (CONTROL). ## Tests `packages/services/service-automation/src/flow-slots-per-package.test.ts` (the shared harness file, per the AGENTS.md rule that a new pin for a component with a shared harness goes into that file as a top-level `describe`), over the real `SchemaRegistry`, the real `flowNameResolver` and a recording trigger: - `[objectstack-ai#33748]` describe: its single-holder CONTROL is flipped to `[objectstack-ai#33905] a name one package holds, disabled at runtime with its slot left armed: not dispatched, said once; re-enabled, it dispatches with no re-arm`. - `[objectstack-ai#33905] the bare entries of a flow whose only holder's package is disabled` (4): `execute` / `getFlow` / `toggleFlow` equal the answers for a name the engine does not hold, durable reads unmoved, re-enable serves again; a subflow call reaches no flow; CONTROLs: a package-less flow, no resolver. - `[objectstack-ai#33893] the served holder of a name a disabled package co-holds keeps its qualified key, armed` (23): - the `FlowSlotTable` unit, `settle` included; - in both registry orders and for each holder disabled, a boot disable (registry holds both, one disabled before the pull) and a runtime disable followed by the re-sync's `withdrawFlowSlot`; - for the runtime disable → withdraw order and for the boot-disable order, the disabled holder then uninstalled and the uninstall's re-sync re-registering the served holder: key `t`, trigger armed under `t` and dispatching, `inboundHookSlot('t')` `undefined` (served, not refused), `getFlowVersionHistory('t')` the slot's two versions, `execute`, and `unregisterFlow('t')` removing it; - the co-holder's return, for the boot disable and the runtime disable, each holder disabled, with the re-sync registering the served holder first and the returning one first (8): both slots armed and dispatched, no refused-body warning; - CONTROL: the returning holder's body really is refused. The served one is declined behind the warning, said once; when the returning holder is registered after all, both are armed; - the stretch between the uninstall and any re-registration (a failed re-sync), first touched by the trigger (the event runs the flow, then the slot is under `t` with its binding) and first touched by a bare entry (`inboundHookSlot`, `getFlow`, version history, `execute` serve it); - CONTROL: an uninstall before the withdraw folds the key back. `packages/runtime/src/domains/automation-addressed-route.test.ts`, new describe `[objectstack-ai#33905] … the bare door answers as its namespaced address (404)` over a real `SchemaRegistry` and the real dispatcher: for a disabled sole holder each bare door (`GET`, `trigger`, legacy trigger, `toggle`, `runs`) answers `404` with the code its address answers, nothing runs or switches; the clone door with the flow as its source answers `404` as its address does, and nothing is registered; CONTROL: enabled, both serve. The service double answers what the engine now answers (the engine half is pinned above). No runtime source changed, so this pin is not ablated; its moving half is ablated as A3 below. ## Acceptance notes - **The boot pull's first holder of a name two SERVED packages ship is declined behind the refused-body warning until the second registers (finding, not changed).** Measured on the engine with this PR's sources (a local commit before the merge), both packages enabled and the registry holding both before the pull: the refused-body warning was said once (`refusedBodyWarnings=1`) and the first slot was re-armed only by the second holder's key move. No body was refused. It predates this PR (unchanged here: M1 still reads every served holder, and telling "refused" from "not yet registered" needs the refusal record, which the ObjectQL-registry pull does not write). Raised in the report for its own card. - **`execute` is gated for every caller**, as the shared-name rule already is (`servedCaller`, amendment 4), so a `subflow` / `map` call of such a flow now gets no flow; listed in the FROM → TO table. - **Doors that read `getFlow` for a durable question** (the clone door's name-taken probe, the definition writes' rollback copy and carried-forward credentials, the DELETE door's existence probe, the flow-start admission's definition read) see `null` for such a flow. The rows above name what moves. Moving them onto a durable read is a runtime change outside this claim, carded as objectstack-ai#34145 (the boot pull's bare-key first-holder decline is objectstack-ai#34051). - **Engine readers that are not entries** (the subflow guards' call key, the activation-row key, `packagedFlowOwner`) do not fold the slot themselves. Between an uninstall and the first fold they read the bare name, and the first registration, fire or bare read folds it. - **`getFlowRuntimeStates` / `listFlows`** still report a disabled sole holder's flow as bound and listed while its trigger is gated (review#2 N2, outside condition 1; unchanged). - **Deviation from the order's suggested route:** the pins are top-level `describe`s in the shared harness files rather than new per-card files (AGENTS.md, ruling record 6583487846). ## Verification All readings are at head `d6a464ce`, under the shared verify lock (`VERDICT command-exit 0`). The commits on this head: - `998cb968` (objectstack-ai#33905) - `9d712d1d` (objectstack-ai#33893) - the merge of `origin/main` `7d42ba09` - `7c193056`: the fold after an uninstall - `b4d4a4a8`: the write-door rows and the clone-source door pin - `ea75f64d`: the re-arm beside a returning co-holder, and the fold on first fire or read - `d6a464ce`: changeset wording `origin/main` has moved on since then. The only change to a file here is objectstack-ai#34090 in `engine.ts`, which touches the start-condition gate in a different region. `git merge-tree --write-tree HEAD origin/main` is clean. <details><summary>Tests (final head)</summary> - `@objectstack/service-automation` test: 282 files / 4024 tests passed. `typecheck`: exit 0. - `src/flow-slots-per-package.test.ts`: 91/91 passed, 27 of them new. - `@objectstack/runtime`, narrowed to the automation domain: 48 files / 1035 tests passed. `typecheck`: exit 0. - Direct dependents of the engine, all passed: - `plugin-trigger-record-change`: 12 files / 122 tests - `plugin-trigger-schedule`: 13 files / 256 tests - `plugin-trigger-api`: 3 files / 73 tests - `plugin-approvals`: 120 files / 1652 tests - Dogfood battery (`pnpm --filter @objectstack/dogfood test`, the CI command, no shard, no path): 467 files passed, 3 skipped (470). 3959 tests passed, 42 skipped (4001). No failures. </details> <details><summary>Ablations (each landed and restored by ablation-replace, `git diff HEAD` empty after each)</summary> | # | Mutation | Reading | |---|---|---| | A1 | trigger gate back to shared names only | 1 of 79 red | | A2 | `resolveFlowKey` disabled-sole-holder gate off | 2 red | | A3 | `servedBareFlowKey` gate off | 1 red | | A4 | `FlowSlotTable.add` qualified keying off | 5 red | | A5 | `FlowSlotTable.remove` keep-key off | 6 red | | A6 | M1 served-holder narrowing off | 4 red | | A8 | the fold in `placeFlowSlot` off | 2 of 80 red: both disable-then-uninstall pins | | A9 | re-arm of a qualified incumbent on the co-holder's add off | 1 of 91 red: the refused-then-registered CONTROL | | A10 | the qualified lone slot's decline no longer waits for a recorded refusal | 5 of 91 red: the four served-first re-enable pins and the CONTROL | | A11 | `recordFlowRefusal`'s re-ask (the decline and its warning) off | 1 of 91 red: the CONTROL | | A12 | the fold in `triggerRun` off | 1 of 91 red: first touched by its trigger | | A13 | the fold in `inboundHookSlot` off | 1 of 91 red: first touched by a bare entry | - A1 to A6 were run at `75b2f32c`, and A8 at `b4d4a4a8`. The code they mutate is unchanged since. - A7 (the qualified-lone `isShared` clause) is retired, because the clause is gone. - A first A10 run planted a syntax error (escaped `&&`) and measured nothing. It was re-run with valid text; the reading above is from that second run. Pre-fix reproduction: this head's test file was run against the `b4d4a4a8` sources. 7 tests were red: the four served-first re-enable pins, the CONTROL and both pins for the stretch before re-registration. The sources were restored and the blob was checked equal to HEAD. The runtime door pin is not ablated, because no runtime source changes. Its moving half is A3. </details> <details><summary>Measured, not pinned (scratch tests, removed)</summary> Clone onto a disabled sole holder, engine half: - `getFlow('t')` is `null`. - A package-less `registerFlow('t', copy)` lands in the package's slot. - Once the package is re-enabled, its trigger runs the copy's body. </details> <details><summary>Gates</summary> - `node scripts/pm/dispatch-gates.mjs --commands` derived 72 families at `d6a464ce`, and all 72 exited 0. `pnpm check:type-check-debt` and `pnpm check:dual-build-cjs-loads` ran under the lock after a full build: 0 raw tsc errors; 123 require entry points across 72 packages. Reconciliation with `--ran`: `72 derived, 72 run, 0 NOT-MEASURED, 0 UNRUN`. - The ADR-0087 registration exited 0. It reads `33748-trigger-disabled-holder.md`, already on `main` from PR objectstack-ai#33890, and this PR's `33905-disabled-sole-holder-flow.md`, which is `not-required (no-migration-prescription)`. - Changeset no-major, empty-changeset and Part-of closing-keyword checks all exited 0. - `check-closing-keyword-parity --body` exited 2, which is informational. The body declares `Fixes` for both cards, which is intended. - `eslint` over the touched files exited 0. The repo-wide `pnpm lint` is left to CI. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QsR2jUZKdq3PK2Sab53cT3 <!-- signed: domain:server#5 · zhuangjianguo · session_01QsR2jUZKdq3PK2Sab53cT3 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Elon · project thread
Part of #33527 (items 1 and 3; item 2, the two plugin-security comments, stays open because open PRs #33478 and #33473 edit those files).
Clause-②: no
Metadata-protocol: none
维护者速读
PATCH /packages/:id/disable)与卸载(DELETE /packages/:id)两个接口,在注册表撤下包之后广播metadata:reloaded { changed: ['app/ID'] },与安装、启用、marketplace 本地卸载同一写法。packages.ts的两处调用。packages/runtime/src/domains/packages.ts停用接口里的wasEnabled判断与卸载接口里的if (registryRemoved)调用;其次是同文件announcePackageReload的失败文案分支。pnpm --filter @objectstack/runtime exec vitest run src/domains/packages-reload-announce.test.ts,预期 10/10 通过。What changes
PATCH /packages/:id/disableannouncesmetadata:reloadedwith{ changed: ['app/ID'] }afterregistry.disablePackage, only when the package was enabled before (read with the registry's ownisPackageDisabled, which mirrors the enable door's reading). Disabling a package that is already disabled announces nothing.DELETE /packages/:idannounces the same payload after the registry withdrawal, the state-record clear and the verb's cleanups, and only when the running registry actually withdrew the package (registryRemoved). This is the order the marketplace install-local uninstall uses ("LAST", and "not when the registry refused"). The announce runs before both answers,200and the partial400, because the package has left the registry either way.announcePackageReload, the same seam (deps.announceKernelEvent) and failure rule as the install and enable doors: a subscriber failure logs onewarnand never changes the answer. The warn text names what a withdrawal keeps (flows stay armed) instead of what an install misses.announcePackageReloadjsdoc now says that an install which lands disabled is announced too, and that this is harmless because subscribers read through the registry's disabled filter. The jsdoc also covers the two withdrawal doors and records the measurement.Decision record, on the order's axes (correctness first, then smallest change, then effort): the withdrawal goes through the existing helper and the existing event. There is no new event, and no engine-side teardown list. The install-local uninstall comment warns that a second teardown is how the two would drift.
Probe (item 1), measured on
origin/maine3f0cfdRig: a real
ObjectKernelwith the SQL driver (better-sqlite3:memory:),ObjectQLPlugin(with its built-in protocol), the realAutomationServicePluginand the realRecordChangeTriggerPlugin, and anHttpDispatcherover the kernel. An authored package is installed throughPOST /packagesand declares a dependency on a code package that servesprobe_ticket. Its flow is saved throughprotocol.saveMetaItem({ type: 'flow', packageId })(publish mode). The flow isrecord-after-createonprobe_ticket, and acreate_recordnode is replaced by a recorder so that a run is observed. The probe was a one-off scratch file and is not committed.origin/mainPATCH /:id/disable→ 200, then insert a rowGET /meta/flowno longer lists itmetadata:reloaded { changed: ['app/ID'] }after the disablePATCH /:id/enable→ 200, insertDELETE /:id→ 200, bindings read right after the answerDELETEansweredSo the premise holds for both doors. Disable left the package armed until a restart.
DELETEleft a window: the withdrawal rode only on the asynchronous mutation sync of the deletedsys_metadatarow, after the door had answered. The authored hooks and actions re-sync on the samemetadata:reloadedsubscriber set. This PR fixes them through the same announce, but did not measure them separately.Probe output, origin/main
Probe output, this branch
Tests
New top-level describe in the shared harness
packages/runtime/src/domains/packages-reload-announce.test.ts(real kernel, realSecurityPlugin, realHttpDispatcher; the recorder now also records whether each held package was disabled when the announce arrived):app/IDonce, with the package held and already disabled.app/IDonce, with the package no longer held.warnnaming the package.The three #33302 expectations gained the recorder's new
offfield (false). Nothing else in them changed.Ablation (one-off, not committed). After the fix was committed,
packages.tswas restored toe3f0cfd422in the working tree only. The test subject is imported fromsrc/, so no rebuild was needed. The mutation was proven on disk: the blob changed and the'uninstalled'anchor count went to 0. Result: 3 failed | 7 passed (10). The red cases were 1, 3 and 5. The green ones were the five #33302 cases and the two no-announce cases, which should stay green. Restore:git checkout HEAD -- PATH, blob equal to the HEAD blob,git diff HEADempty.Verification
vitest run src/domains/packages-reload-announce.test.ts: 10 passed (10).pnpm --filter @objectstack/runtime typecheck: exit 0 (check:test-typecheck: OK).eslint --no-inline-configon the two changed source files: exit 0.node scripts/check-test-source-alias.mjs: exit 0.Session: https://claude.ai/code/session_016WV4cxHwXNcGcAHNerZsom
🤖 Generated with Claude Code